<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window</title>
<link href="CSS/cssAll.css" rel="stylesheet" type="text/css" />
</head>

<body>
<!--<div class="windowError">
	<div class="ErrorHeader"></div>
	<div class="ErrorCon">1</div>
	<div class="ErrorBottom">
		<input type="button" value="确定" />
	</div>
</div>-->
<input type="button" value="Error" onclick="Cerror()" />
<input type="button" value="Warning" onclick="Cwarning()" />
<input type="button" value="Confirm" onclick="CConfirm(this)" />
<input type="button" value="Prompt" onclick="CPrompt()" />
</textarea>
</body>
</html>
<script src="JS/showPrint.js" ></script>
<script src="JS/func.js"></script>
<script language="javascript">
var box = new ShowDialog();
var temp;
window.onload =function(){box.Warning('欢迎','欢迎你的到来～')}
function Cerror(){	
	box.Alert('ErrorTittle','ErrorContent');
}
function Cwarning(){
	box.Warning('WarningTittle','WarningContent');
}
function CConfirm(){
	box.Confirm('ConfirmTittle','ConfirmContent');
}
function CPrompt(){
	box.Prompt('PromptTittle','PromptContent');	
}

function ShowDialog(sType,sTittle,sContent){
	this.type=sType;
	this.tittle=sTittle;
	this.content=sContent;
}
ShowDialog.prototype.Alert=function (sTittle,sContent){
	this.type='Error';
	this.tittle=sTittle;
	this.content=sContent;
	this.create();
}
ShowDialog.prototype.Warning=function (sTittle,sContent){
	this.type='Warning';
	this.tittle=sTittle;
	this.content=sContent;
	this.create();
}
ShowDialog.prototype.Confirm=function (sTittle,sContent){
	this.type='Confirm';
	this.tittle=sTittle;
	this.content=sContent;
	this.create();
}
ShowDialog.prototype.Prompt=function (sTittle,sContent){
	this.type='Prompt';
	this.tittle=sTittle;
	this.content=sContent;
	this.create();
}
ShowDialog.prototype.create=function (){
	var w,h,nLeft,nTop,flag;
	h=document.documentElement.clientHeight;
	w=document.documentElement.clientWidth;
	var dialogBoxMask = document.createElement('div');
	dialogBoxMask.className = 'windowmask';
	var dialogBox= document.createElement('div');
	dialogBox.className = 'window'+this.type;
	var dialogHeader = document.createElement('div');
	dialogHeader.className = this.type+'Header';
	var oTextTittle = document.createTextNode(this.tittle);
	var dialogCon = document.createElement('div');
	dialogCon.className = this.type+'Con';
	if(this.type!='Prompt'){
		var oTextCon = document.createTextNode(this.content);
		dialogCon.appendChild(oTextCon);
	}else{
		var oP = document.createElement('p');
		var oTextCon = document.createTextNode(this.content);
		var oArea = document.createElement('textarea');
		oArea.setAttribute('rows','5');
		oArea.setAttribute('cols','50');
		oP.appendChild(oTextCon);
		dialogCon.appendChild(oP);
		dialogCon.appendChild(oArea);
	}
	var dialogBtBox = document.createElement('div');
	dialogBtBox.className = 'dialogBottom';
	switch (this.type){
		case 'Error':
		case 'Warning':
			var dialogBtOk = document.createElement('input');
			dialogBtOk.setAttribute('type','button');
			dialogBtOk.setAttribute('value','确定');
			dialogBtOk.className='dialogBt';
			bindEvent(dialogBtOk,'click',function(){ document.body.removeChild(dialogBox); document.body.removeChild(dialogBoxMask);return true;});
			dialogBtBox.appendChild(dialogBtOk);
			break;
		case 'Confirm':
		case 'Prompt':
			var dialogBtOk = document.createElement('input');
			dialogBtOk.setAttribute('type','button');
			dialogBtOk.setAttribute('value','确定');
			dialogBtOk.className='dialogBt';
			bindEvent(dialogBtOk,'click',function(){ document.body.removeChild(dialogBox); document.body.removeChild(dialogBoxMask);return true;});
			var dialogBtCancel = document.createElement('input');
			dialogBtCancel.setAttribute('type','button');
			dialogBtCancel.setAttribute('value','取消');
			dialogBtCancel.className='dialogBt';
			bindEvent(dialogBtCancel,'click',function(){ document.body.removeChild(dialogBox); document.body.removeChild(dialogBoxMask);return false;});
//			bindEvent(dialogBtCancel,'click',this.Cancel(dialogBox));
			dialogBtBox.appendChild(dialogBtOk);
			dialogBtBox.appendChild(dialogBtCancel);
			break;
	}
	dialogHeader.appendChild(oTextTittle);
	dialogBox.appendChild(dialogHeader);
	dialogBox.appendChild(dialogCon);
	dialogBox.appendChild(dialogBtBox);
	document.body.appendChild(dialogBox);
	document.body.appendChild(dialogBoxMask);
	nLeft=(w-dialogBox.offsetWidth)/2;
	nTop=(h-dialogBox.offsetHeight)/2;
	dialogBox.style.left=nLeft+'px';
	dialogBox.style.top=nTop+'px';
}
//ShowDialog.prototype.Cancel = function(sDialogBox){
//	var oT = document.createElement('div'); document.body.replaceChild(oT,sDialogBox);	
//}


</script>